<include file="public@header" />
</head>
<body>
	<div class="wrap data_chart">
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script src="__STATIC__/js/echarts/echarts.min.js"></script>
<script>
	$(function(){
        var data = {$data|json_encode=###};
        $.each(data,function(key,item){
            var option = {
                title : {
                    x:'center'
                },
                tooltip : {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: []
                },
                series : [
                    {
                        type: 'pie',
                        radius : '55%',
                        center: ['50%', '60%'],
                        data:[
                        ]
                    }
                ]
            };

            option.title.text = item.title;
            option.series[0].name = item.name;
            $.each(item.data,function(k,value){
                console.log(value);
                option.legend.data.push(value.name);
                option.series[0].data.push({value:value.count,name:value.name,nature:value.nature});
            });
            $('.data_chart').append('<div id="chart_'+key+'" class="col-sm-6" style="height:400px;"></div>');
            var myChart = echarts.init(document.getElementById('chart_'+key));
            myChart.setOption(option);
            myChart.on('click', function (params) {
                $.ajax({
					url:'{:cmf_url("detail")}',
					data:{type:key,value:params.data.value},
					success:function(data) {
					    console.log(data);
					}
				});
                openIframeLayer('<div>asdf</div>',params.name,{type:1});
                console.log(params.data);
            });
            $(window).resize(function(){
                myChart.resize();
            });
        });
    })
</script>
</body>
</html>